﻿<html>
<head>
	<title>注册成功</title>
</head>
<body>
<h1>恭喜你，注册成功</h1>
<?php 
	if (isset($_POST['submitted'])) {
		$text=$_POST['text'];
		$password=$_POST['password'];
		
		if (!$text || !$password) {
		echo "数据出错，请重新输入.<br />";
		exit;
		}
		
		if (!get_magic_quotes_gpc()){
			$text = addslashes($text);
			$password = addslashes($password);
		}
		
		$user = 'abc';	//用户名
		$pass = '';	//密码
		
		$db = new mysqli('localhost', $user, $pass, 'test');
		
		if (mysqli_connect_errno()) {
			echo "无法连接数据库";
			exit;
		}
		//$query = "sekect * from test 
		//			('".$text."', '".$password."')";
		$query = "INSERT INTO users (`name`, `password`) VALUES('$text', '$password')";
		echo $query;
		$result = $db->query($query);
		
		if ($result){
		// echo $db->affected_rows."哈哈哈.";
		// die;
			echo 'ok';
		}else{
			echo ".出错.";
		}
	}	
	?>
	
	<form method="post" action="yo.php">
		姓名：<input type="text" name="text" value="" /><br />
		密码：<input type="password" name="password" value="" /><br />
		<input type="submit" name="submitted" value="提交" />
	</form>
	</body>
	</html>